#ifndef _IT_SIMULA_UART_H  
#define _IT_SIMULA_UART_H  
#include "aky_define.h"

#define SIMUL_RX_PORT GPIO1
#define SIMUL_RX_PIN Pin_7
#define SIMUL_RX (((LINK2(CHAR_P,SIMUL_RX_PORT) & SIMUL_RX_PIN) != 0x00) ? (0x01) : (0x00))//寄存器方式
#define SIMUL_RX_PROT_REG  LINK3(CHAR_P,SIMUL_RX_PORT,CHAR_M)//PxM
#define SIMUL_RX_UP_REG  LINK3(CHAR_P,SIMUL_RX_PORT,CHAR_UR)

#define SIMUL_TX_PORT GPIO0 //
#define SIMUL_TX_PIN Pin_2
#define SIMUL_TX_H (LINK2(CHAR_P,SIMUL_TX_PORT) |= SIMUL_TX_PIN)
#define SIMUL_TX_L (LINK2(CHAR_P,SIMUL_TX_PORT) &= ~(SIMUL_TX_PIN))
#define SIMUL_TX_PROT_REG  LINK3(CHAR_P,SIMUL_TX_PORT,CHAR_M)//PxM
#define SIMUL_TX_UP_REG  LINK3(CHAR_P,SIMUL_TX_PORT,CHAR_UR)

#define SIMUL_MAX_RX_SIZE (32ul)

#define SIMUL_UART_ONE_TICK (2ul)
#define SIMUL_UART_RX_TIME_OUT_TICK (SIMUL_UART_ONE_TICK * 2)

typedef enum
{
    RX_IDLE = 0, //空闲
    RX_START_BIT, //开始1bit
    RX_READ_8_BIT_DAT, //8bit数据
    RX_READ_END_BIT,//结束1bit
    RX_READ_ERR,//出错
    RX_READ_1BYTE_SUCC,//成功接收到一字节数据

}e_simul_rx_stat_t;

typedef enum
{
    TX_IDLE = 0,//空闲
    TX_START_BIT,//开始1bit
    TX_SEND_8_BIT_DAT,//8bit数据
    TX_SEND_END_BIT,//结束1bit
    TX_SEND_ERR,//出错
    TX_SEND_1BYTE_SUCC,//成功发送一字节数据

}e_simul_tx_stat_t;

void it_simula_uart_init(void);
void it_simula_uart_deinit(void);
void it_simula_uart_pro(void);
void it_simula_uart_send_byte(unsigned char dat);
unsigned char it_simula_uart_get_byte(void);
unsigned char get_simul_uart_rx_stat(void);
void it_simula_uart_io_init(void);

#endif //

